<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script type="text/javascript">
    
    Date.prototype.format = function(){
         //now 获取 不同的字段 属性
        let year = this.getFullYear()
        let month = this.getMonth()
        let date = this.getDate() //月中的第几天
        let day = this.getDay()   //星期的 第几天
        let hour = this.getHours()
        let min = this.getMinutes()
        let sec = this.getSeconds()
        return ` ${year}-${month+1}-${date}  ${hour}:${min}:${sec}  `
    }
    //    创建时间对象
    let now = new Date()
    console.log("now ",now);
    

    //now 获取 不同的字段 属性
    let year = now.getFullYear()
    let month = now.getMonth()
    let date = now.getDate() //月中的第几天
    let day = now.getDay()   //星期的 第几天
    let hour = now.getHours()
    let min = now.getMinutes()
    let sec = now.getSeconds()
    
    console.log(`day  ${day} `);
    console.log(`当前时间  ${year}-${month+1}-${date}  ${hour}:${min}:${sec}   `);
    

       let now2 = new Date()

    console.log("now2 格式化: ", now2.format());




    </script>



    <button onclick="sayHi()">点我</button>
</body>
</html>